﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace WebApp
{
    public partial class IN : System.Web.UI.Page
    {
       
        protected void Timer2_Tick(object sender, EventArgs e)
        {
            this.Label2.Text = System.DateTime.Now.ToString();
        }

        protected void btnTeaIn_Click(object sender, EventArgs e)
        {
            try
            {
                string strCn = "server=pc.hstc.cn;database=dhd2014112138;uid=2014112138;pwd=19960516";
                SqlConnection conn = new SqlConnection(strCn);
                conn.Open();

                StringBuilder sb = new StringBuilder(1024);
                sb.Append("INSERT INTO UserTeacher ");
                sb.Append("                (TeaName, Password) ");
                sb.Append("VALUES   (@TeaName,@Password) ");
                SqlParameter[] pms = new SqlParameter[2];
                pms[0] = new SqlParameter("@TeaName", this.txtTeaNa.Text);
                pms[1] = new SqlParameter("@Password", this.txtTeaPwd1.Text);
           
                int intResult = SqlHelper.ExecuteNonQuery(sb.ToString(), pms);
                if (intResult > 0)
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('注册成功！请返回登录页面进行登录！')", true);
                }
            }
            catch (Exception ex)
            {
                this.lblTeaInfo.Text = "注册失败！用户已存在，请重新注册……具体原因：" + ex.Message;
            }
        }

        protected void btnNew1_Click(object sender, EventArgs e)
        {
            this.txtTeaNa.Text = "";
            this.txtTeaPwd1.Text = "";
            this.txtTeaPwd2.Text = "";
        }

      
    }
}